﻿Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports Microsoft.VisualBasic

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService
     Inherits System.Web.Services.WebService

    ' Retorna un string que contiene informacion del dia con el formato [Nombre], [numero] de [mes] de [anio]
    <WebMethod()> _
    Public Function ObtenerFechaHora() As String
        Dim fechahora As String = String.Format("{0:dd/MM/yyyy}", DateTime.Now)
        Dim nombredia As String = "Desconocido"
        Dim nombremes As String = "Desconocido"

        ' Guardo el nombre del dia en una variable
        If Weekday(DateTime.Now) = FirstDayOfWeek.Sunday Then
            nombredia = "Domingo"
        ElseIf Weekday(DateTime.Now) = FirstDayOfWeek.Monday Then
            nombredia = "Lunes"
        ElseIf Weekday(DateTime.Now) = FirstDayOfWeek.Tuesday Then
            nombredia = "Martes"
        ElseIf Weekday(DateTime.Now) = FirstDayOfWeek.Wednesday Then
            nombredia = "Miecoles"
        ElseIf Weekday(DateTime.Now) = FirstDayOfWeek.Thursday Then
            nombredia = "Jueves"
        ElseIf Weekday(DateTime.Now) = FirstDayOfWeek.Friday Then
            nombredia = "Viernes"
        ElseIf Weekday(DateTime.Now) = FirstDayOfWeek.Saturday Then
            nombredia = "Sabado"
        End If

        ' Guardo el nombre del mes en una variable
        If Month(DateTime.Now) = 1 Then
            nombremes = "Enero"
        ElseIf Month(DateTime.Now) = 2 Then
            nombremes = "Febrero"
        ElseIf Month(DateTime.Now) = 3 Then
            nombremes = "Marzo"
        ElseIf Month(DateTime.Now) = 4 Then
            nombremes = "Abril"
        ElseIf Month(DateTime.Now) = 5 Then
            nombremes = "Mayo"
        ElseIf Month(DateTime.Now) = 6 Then
            nombremes = "Junio"
        ElseIf Month(DateTime.Now) = 7 Then
            nombremes = "Julio"
        ElseIf Month(DateTime.Now) = 8 Then
            nombremes = "Agosto"
        ElseIf Month(DateTime.Now) = 9 Then
            nombremes = "Septiembre"
        ElseIf Month(DateTime.Now) = 10 Then
            nombremes = "Octubre"
        ElseIf Month(DateTime.Now) = 11 Then
            nombremes = "Noviembre"
        ElseIf Month(DateTime.Now) = 12 Then
            nombremes = "Diciembre"
        End If

        Return nombredia + ", " + String.Format("{0:dd}", DateTime.Now) + " de " + nombremes + " de 2014"
    End Function

End Class